package LQB;

import java.util.HashSet;
import java.util.Set;

public class 全排列 {
    static void f(int [] arr,int k){
        if (k==4){
            check(arr);
        }
        for (int i = k; i < 4; i++) {
            int t=arr[k];
            arr[k]=arr[i];
            arr[i]=k;

            f(arr,k+1);
            t=arr[k];
            arr[k]=arr[i];
            arr[i]=t;
        }
    }
    static Set<Integer> set=new HashSet<>();
    private static void check(int [] arr){
        int x=1000*arr[0]+100*arr[1]+10*arr[2]+1*arr[3];
        boolean flag=true;
        for (int i = 2; i < Math.sqrt(x); i++) {
            if (x%i==0){
                flag=false;
                break;
            }
            if (flag){
                set.add(x);
            }
        }
    }
    public static void main(String[] args) {
        int [] arr={1,4,9,9};
        f(arr,0);
        System.out.println(set.size());
    }
}
